<template>
    <div class="flex flex-1 flex-col justify-center px-6 py-5 lg:px-8">
        <div class="sm:mx-auto sm:w-full sm:max-w-sm flex flex-col justify-center items-center">
          <img src="../assets/logo.png" class="w-32">
            <h2 class="text-center text-2xl font-bold leading-9 tracking-tight">欢迎</h2>
        </div>
        <div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
            <form class="space-y-6" action="#" @submit.prevent="userLogin">
                <div>
                    <label for="email" class="block text-sm font-medium leading-6 text-left">邮箱</label>
                    <div class="mt-2">
                        <input id="email" name="email" type="email" autocomplete="email" required=""
                               v-model="user.email"
                               class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"/>
                    </div>

                    <div class="flex items-center justify-between mt-5">
                        <label for="password" class="block text-sm font-medium leading-6">密码</label>
                        <div class="text-sm">
                            <a @click="router.push('/forgetPassword')"  class=" hover:text-accent link">忘记密码?</a>
                        </div>
                    </div>
                    <div class="mt-2">
                        <input v-model="user.password" id="password" name="password" type="password"
                               autocomplete="current-password"
                               class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"/>
                    </div>

                    <button type="submit"
                            class="flex my-2 w-full justify-center rounded-md bg-primary px-3 py-1.5 mt-8 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-secondary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
                        登录
                    </button>
                    <div class="text-sm w-full relative">
                        <router-link to="/register"
                                     href="#"
                                     class="absolute right-0 text-right w-auto  hover:text-accent link">
                            立即注册一个账户
                        </router-link>
                    </div>
                </div>
            </form>
        </div>
    </div>
</template>

<script setup lang="ts">
import {reactive, ref} from "vue";
import {useAuthStore} from "../plugins/pinia.ts";
import {useToast} from "vue-toastification";
import router from "../plugins/router.ts";
let user = reactive({
    email: null,
    password: null,
})
function userLogin() {
    let authStore = useAuthStore();
    authStore.login(user);
}


</script>

<style scoped>


</style>
